//q4.cpp
//This programs takes two strings and return an array with the location of the second string index in the other.
//
//Binyamin 18 Jan 2018
//--------------------------------------------------------------------------------------------------------------

#include<iostream>
#include<string.h>

using namespace std;

int *find_occur(char *text, char *str, int *size)
{
	int data[20];
	int *ret;
	int i; // looper
	i=0;
	*size = 0;
	while(i< strlen(text))
	{
		data[*size] = strstr(text + i, str) - text;
		i+= data[*size] + 1;
		(*size)++;
	}
	ret = new int[*size];
	for(i=0;i<*size;i++)
	{
		ret[i] = data[i];
	}
	return ret;

}
int main()
{
	int i; //looper for printing
	int *arr; //get the returning array
	int size; // size of the new array
	char data[255]; //user input
	char str[255]; // user input
	cout << "Please insert two arrays" << endl;
	cin >> data >> str;
	arr = find_occur(data, str, &size);
	for(i=0;i<size;i++)
	{
		cout << arr[i] << '\t';
	}
	cout << endl;
}
//output
//Please insert two arrays
//aababacdaba
//aba
//1	3	8	
